{include file="admin/site_header.tpl"}

<body id="login">
	<div class="box box-50 altbox">
		<div class="boxin">
			<div class="header">
				<h3>AMG - Web Administration Site</h3>
			</div>
			<form id="login_form" class="basic">
				<div class="inner-form">
					<div id="msg" class="msg msg-error hidden"><p><strong>message title</strong> message content</p></div>

					<dl style="margin:0 auto; width:80%;">
						<dt><label><b>User Name </b></label></dt>
						<dd><input id="username" class="txt mandatory" type="text" /></dd>

						
						<dt><label><b>Password </b></label></dt>
						<dd><input id="passwd" class="txt mandatory" type="password" /></dd>

						<dt>&nbsp;</dt>
						<dd><button id="btnlogin" class="button altbutton" type="button"/>Log In </botton></dd>
					</dl>
				</div>
			</form>
		</div>
	</div>
	
<script type="text/javascript">
$(document).ready(function(){
	$('#username').focus();
	$('#btnlogin').live( 'click', function() {
		//alert('login clicked');

		var _post = [{ name:'ts', value:new Date().getTime() }], _err  = 0;

		$('input', $('#login_form')).each(function () {
			var _val = $(this).val();
			if($(this).hasClass('mandatory') && ! _val) {
				_err=1;
				$(this).addClass('error');
			}
			_post.push({ name:this.id, value:_val });
		});

		if(_err) {
			$('#msg').removeClass('hidden').addClass('display').html('<p>field Harus di ISI..</p>');
		} else {
			$.post('{$site.site}adminajax/login/', _post, function(response) {
				if (response=="0"){
					$('#msg').removeClass('hidden').addClass('display').html('<p>Invalid Username / Password !!</p>');
				} else if (response=="1"){
					$('#msg').removeClass('hidden').addClass('display').html('<p>User anda belum aktif !!</p>');
				} else {
					top.location.href = response;
				}
			});
		}
	});
});
</script>
</body>
{include file="admin/site_footer.tpl"}